//
//  SplitViewController.swift
//  myhub
//
//  Created by x on 2024/6/3.
//

import UIKit
import XDesignKit
import RxCocoa
import NSObject_Rx

open class SplitViewController: UISplitViewController {
    open override var preferredStatusBarStyle: UIStatusBarStyle {
        return globalStatusBarStyle.value
    }

    open override func viewDidLoad() {
        super.viewDidLoad()

        delegate = self
        preferredDisplayMode = .allVisible

        globalStatusBarStyle.mapToVoid().subscribe(onNext: {
            [weak self] () in
            self?.setNeedsStatusBarAppearanceUpdate()
        }).disposed(by: rx.disposeBag)
    }
}

extension SplitViewController: UISplitViewControllerDelegate {
    open func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController) -> Bool {
        return true
    }
}
